import BaseModel from "./BaseModel";
import { ItemState } from "../tools/Define";

//所有道具的父类
export default class BaseItemModel extends BaseModel {

    static UPDATE_STATE: string = 'update_item_state'

    // 数量 [0 - 当前 1 - 旧值]
    protected num: [number, number] = [0, 0];
    protected ID: number;
    protected type: number;
    //是否已经解锁
    protected state: ItemState;


    setState(s: ItemState) {
        this.state = s;
        this.emit(BaseItemModel.UPDATE_STATE)
    }

    isOpen() {
        return true;
    }

    getState() {
        return this.state
    }

    getName() {
        return ''
    }

    getIcon() {
        return ''
    }

    getDesc() {
        return ''
    }

    getTipDesc() {
        return this.getName()
    }


    setNum(num): boolean {
        let updated = false;

        this.num[1] = this.num[0];
        updated = num != this.num[1];

        this.num[0] = num;
        return updated;
    }

    getPreNum() {
        return this.num[1];
    }

    getNum() {
        return this.num[0];
    }

    getDeltaNum() {
        return this.num[0] - this.num[1];
    }

    getType() {
        return this.type;
    }

    setType(t) {
        this.type = t;
    }

    setID(id) {
        this.ID = id;
        this.type = Math.floor(this.ID / 1000)
    }

    getID() {
        return this.ID;
    }




    getTime() {
        return -1;
    }

    getTipID() {
        return null;
    }

    getScale() {
        return 1;
    }


    getCostItem() {
        return null
    }

}
